# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Oleksandr Natalenko <oleksandr@natalenko.name>
# Contributor: Darren Ng <$(base64 --decode <<<VW4xR2ZuQGdtYWlsLmNvbQo=)>
# Contributor: Dan Bryant <$(base64 --decode <<<VanVzdGRhbjk2QGdtYWlsLmNvbQo=)>

pkgname=uasm
pkgver=2.56.2
pkgrel=1
pkgdesc='A MASM-compatible assembler'
arch=('loong64' 'x86_64')
url='http://www.terraspace.co.uk/uasm.html'
# Previous versions were licensed under the following licenses:
# - JWasm License
# - Sybase Open Watcom Public License 1.0
# Of which both are the same license with the following SPDX
# identifier: Watcom-1.0.
# The uasm-nocolor script uses code from stackoverflow, which
# is licensed under CC-BY-SA-3.0.
license=(
  'custom:Watcom-1.0'
  'custom:CC-BY-SA-3.0'
)
makedepends=('git')
optdepends=('sed: for uasm-nocolor')
_commit='4dc0a4f96e2296c2e56c9224a2a0453c99470e2c'
source=(
  "$pkgname::git+https://github.com/Terraspace/UASM#commit=$_commit"
  'uasm_extended_guide_v2.52.pdf::http://www.terraspace.co.uk/uasm252_ext.pdf'
  'uasm-nocolor'
)
sha512sums=('SKIP'
            '8848dc5f174c4c533a9b4dbd84da86fc8c8d0e67afa5648a016228c739a8e0e359c6ae897618ebab50b5b1ca64b879f037bfb6406c6fe84fb28eb59678989cb2'
            '6099e122db071419e2158f37611726d6e2d9a73a0a6966320c8b7cd0621730df52078eaec70ab03358a40aece7b3312072370ba864cfd7f00f92c791ef98f0ca')
b2sums=('SKIP'
        '37b1cbee60d79dd6bd9fd66b9a4c25a25d2dc52a582c6dd5d1087b48f5f507bda667a5687d3774ae57f9bc289553d52573886d1e48cd2c5098e57bab79074477'
        '29f03fede4f03363b106afe2a502c45b3ef8dcf5ae681f5e0f495908c83309f34b9f6fc663976814f03d3a73e4ca62762963caaa4c96a6c36b0c4ad806b1e1db')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  # fix FTBFS
  # https://gcc.gnu.org/gcc-10/porting_to.html#common
  make CC="gcc -fcommon" -f gccLinux64.mak
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" GccUnixR/uasm "$srcdir/uasm-nocolor"

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" \
    {Readme,History}.txt \
    README.md \
    Doc/* \
    "$srcdir/uasm_extended_guide_v2.52.pdf"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" License.txt
}
